package 线程停止;
//判断线程是否停止有两种方法：
//1)this.interrupted():判断当前线程是否已经中断
//		public static boolean interrupted()
//2）this.isInterrupted():判断线程是否已经中断
//		public boolean isInterrupted()
class mythe extends Thread
{
	public void run()
	{
	super.run();
	for(int i=0;i<500;i++)
	{
		System.out.println("i="+(i+1));
		//System.out.println("this.interrupted() "+this.interrupted());

	}
	}
	
	
}
public class Test1_32 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try
		{
			mythe thread=new mythe();
			thread.start();
			Thread.sleep(1000);
			//thread.interrupt();
			Thread.currentThread().interrupt();
			System.out.println("this.interrupted()1 "+Thread.interrupted());
			System.out.println("this.Interrupted()2 "+Thread.interrupted());
			System.out.println("end");
			//两次调用interrupted()方法，第一次是true,第二次是false，因为interrupted具有清除状态的功能
			//第一次调用已经清除了其中中断状态之后，第二次调用了检验完中断状态前，当前线程再次中断的情况除外

			


		}
		catch(InterruptedException e)
		{
			System.out.println("main catch");
			e.printStackTrace();
			System.out.println("end");
		}
	}

}
